from ultralytics import YOLO
import cv2
# Load a pretrained YOLOv8n model
model = YOLO(r'/home/jovyan/exp_3721/runs/detect/train/weights/best.pt')

# Define path to the image file
source = r'/home/jovyan/exp_3721/datasets/val/images/21.jpg'

# Run inference on the source
results = model.predict(
    source,
    conf=0.25,
    iou=0.5,
    imgsz=640,
    save=True,
    )

id2name = results[0].names
res_img = results[0].plot()
cv2.imwrite("a.jpg", res_img)

